package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-08-12 16:32
 */
public class Solution_0806 {
    public int[] numberOfLines(int[] widths, String s) {
        int res = 0;
        int needRow = 0;
        for (int i = 0; i < s.length(); ) {
            if (widths[s.charAt(i) - 'a'] + res > 100) {
                needRow++;
                res = 0;
            } else {
                res += widths[s.charAt(i) - 'a'];
                i++;
            }
        }
        int[] ints = new int[2];
        ints[0] = needRow + 1;
        ints[1] = res;
        return ints;
    }
}
